package com.atguigu.yygh.order.config;


import com.atguigu.yygh.common.config.MqConst;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;

// 生产者端设置Rabbitmq的消息队列信息
//@Configuration
public class OrderConfig {

    @Bean
    public Exchange getExchange(){
        return ExchangeBuilder.directExchange(MqConst.EXCHANGE_DIRECT_ORDER).durable(true).build();
    }

    @Bean
    public Queue getQueue(){
        return QueueBuilder.durable(MqConst.QUEUE_ORDER).build();
    }

//    @Qualifier("getQueue") 通过队列的方法名进行引用
    @Bean
    public Binding bingding(@Qualifier("getQueue") Queue queue,
                            @Qualifier("getExchange") Exchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with(MqConst.ROUTING_ORDER).noargs();
    }
}
